package org.gtugs.raffler.interfaces;

import java.util.HashMap;
import java.util.List;

import org.alljoyn.bus.BusException;
import org.alljoyn.bus.annotation.BusInterface;
import org.alljoyn.bus.annotation.BusMethod;
import org.gtugs.raffler.pojo.Participant;
import org.gtugs.raffler.pojo.Prize;
import org.gtugs.raffler.pojo.Raffle;

@BusInterface(name = "org.gtugs.raffler.interfaces.RaffleMasterInterface")
public interface RaffleMasterInterface {
	
	/*
     * Name used as the well-known name and the advertised name.  This name must be a unique name
     * both to the bus and to the network as a whole.  The name uses reverse URL style of naming.
     */
	public static final String SERVICE_NAME = "org.gtugs.raffler";
    public static final short CONTACT_PORT=42;
    
    /* These are the messages sent to the BusHandler from the UI. */
    public static final int CONNECT = 1;
    public static final int DISCONNECT = 2;

	
	/**
	 * @return A list of raffles available on the current master
	 */
	@BusMethod
	public List<Raffle> getRaffles() throws BusException;
	
	/**
	 * @param raffle The raffle to be registered on
	 * @param participant The participant to register for this raffle
	 * @return boolean value if registration happened or not, will fail if raffle already ended
	 */
	@BusMethod
	public boolean registerForRaffle(Raffle raffle, Participant participant) throws BusException;
	
	/**
	 * @param raffle The raffle you want the list from
	 * @return the list of available prizes, sorted by weight
	 */
	@BusMethod
	public List<Prize> getPrize(Raffle raffle) throws BusException;
	
	/**
	 * @param raffle The raffle you want the list from
	 * @return a list of all registered participants
	 */
	@BusMethod
	public List<Participant> getParticipants(Raffle raffle) throws BusException;
	
	/**
	 * @param raffle The raffle your interested in
	 * @return The final drawing list with the winners associated to all prizes, will return NULL if drawing has not yet happened
	 */
	@BusMethod
	public HashMap<Prize, Participant> getFinalDrawing(Raffle raffle) throws BusException;

}
